﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CMS.Repository.Translator
{
    public class DepartmentTranslator
    {
        public static List<CMS.Model.Department> ToDepartmentModelList(List<CMS.Repository.Department> department)// translator Department Entity Framework to Department 
        {
            List<CMS.Model.Department> dep = new List<CMS.Model.Department>();

            foreach (var a in department)
            {
                CMS.Model.Department b = new CMS.Model.Department()
                {
                    DepartmentId = a.DepartmentId,
                    DepartmentName = a.DepartmentName,
                    Manager = a.Manager,
                    Phone = a.Phone,
                    Remark = a.Remark
                };

                dep.Add(b);

            }
            return dep;
        }

        public static List<CMS.Repository.Department> ToDepartmentEFList(List<CMS.Model.Department> departmentInstance)
        {
            List<CMS.Repository.Department> dep = new List<CMS.Repository.Department>();
            foreach (var a in departmentInstance)
            {
                CMS.Repository.Department b = new CMS.Repository.Department()
                {
                    DepartmentId = a.DepartmentId == 0 ? 0 : a.DepartmentId,
                    DepartmentName = a.DepartmentName == null ? "" : a.DepartmentName,
                    Manager = a.Manager == null ? "" : a.Manager,
                    Phone = a.Phone == null ? "" : a.Phone,
                    Remark = a.Remark == null ? "" : a.Remark
                };

                dep.Add(b);
            }
            return dep;
        }
    }
}
